chrome.storage.sync.get([StorageKey.ENABLE_PRIORITY, StorageKey.SCAN_TAGS], function (result) {
    document.querySelector('#enable_priority').checked = result[StorageKey.ENABLE_PRIORITY];
    document.querySelector('#scanning_tags').value = result[StorageKey.SCAN_TAGS] || DefaultScanTags;
    document.querySelector('#move_video_to_body').checked = result[StorageKey.MOVE_VIDEO_TO_BODY];
});


document.querySelector('#save_success').style.display = "none";
document.querySelector('#save').addEventListener("click", function() {
    chrome.storage.sync.set({
        [StorageKey.ENABLE_PRIORITY]: document.querySelector('#enable_priority').checked,
        [StorageKey.SCAN_TAGS]: document.querySelector('#scanning_tags').value,
        [StorageKey.MOVE_VIDEO_TO_BODY]: document.querySelector('#move_video_to_body').checked,
    }, function() {
        document.querySelector('#save_success').style.display = "";
        setTimeout(() => {
            document.querySelector('#save_success').style.display = "none";
        }, 2000);
    });
});